/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ControlEscolar.DAOs;

/**
 *
 * @author listico
 */


import com.ControlEscolar.Beans.ExamReport;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Listico
 */
public class ExamReportDAO extends AbstractDAO <ExamReport> {

    @Override
    public void add(ExamReport object) throws DAOException {

    }

    @Override
    public int delete(String condition) throws DAOException {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public int update(ExamReport object) throws DAOException {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public ArrayList<ExamReport> query() throws DAOException {
         try {
            String sql = "SELECT e.`studentKey`,c.ID_Curriculum," +
                    " e.`subjectKey`, e.`examType`,  e.`examGrade` " +
                    " FROM exams e join enrollment c;";
            return connection.executeQuery(sql, ExamReport.class);
         } catch (Exception ex) {
            throw new DAOException();
        }
    }
    public int OpportunityNumbers(String[] dataCondition) throws DAOException{
        try {
            
            String sql = "select count(*) from exams where " +
                    "subjectKey=\"" + dataCondition[3] +
                    "\" and studentKey=\"" + dataCondition[1] +
                    "\"" + " and ID_Curriculum=" + dataCondition[2];
      
            ResultSet rs=connection.executeViews(sql);
            
            return (Integer)rs.findColumn("count(*)");
            
        } catch (Exception ex) {
            throw new DAOException();
        }
    }
}